#pragma once

#include "BasicEvent.h"
#include <windows.h>

namespace events {


class MemoryEvent : public BasicEvent
{
public:
	enum VIRTUAL_ALLOC_TYPE {
		VallocCommit,
		VallocReserve,
		VallocReset
	};

public:
	/// required by serialization
	inline MemoryEvent(void) : BasicEvent(BasicEvent::EVENT_MEMORY), _size((SIZE_T)0) {}

	inline MemoryEvent(DWORD type, SIZE_T size)
		: BasicEvent(BasicEvent::EVENT_MEMORY), _size(size)
	{
		if (type & MEM_RESET)
			_type = VallocReset;
		else if (type & MEM_RESERVE)
			_type = VallocReserve;
		else  // MEM_COMMIT
			_type = VallocCommit;
	}

	virtual ~MemoryEvent(void) {}

	// implementing ISerializable
public:
	virtual void saveToStream(std::ostream &os) const;
	virtual void readFromStream(std::istream &is);
	virtual void writeDebugInfo(std::ostream &os) const;

private:
	VIRTUAL_ALLOC_TYPE _type;
	GenericDataType<SIZE_T> _size;
};


}  // end namespace
